<template>
	<view class="page-wrap" :data-theme="theme" :class="theme" :style="globalColor.style">
		<HeadCustom :isSpace="false" :isBlur="false" :isAppBtn="false" :isHome="!isApp">
			<view v-if="isApp" class="action-btn fboxRow Ycenter Xcenter" slot="right" @tap="goPage"><text class="bwfont bw-zhichanggerenguanli1"></text></view>
		</HeadCustom>
		<view class="wrap" v-if="isLogin">
			<view class="bg-head">
				<view :style="{height: statusBarHeight+'px'}"></view>
				<view class="management-hd">
					<view class="fboxRow">
						<image class="avatar" :src="detail.companyLogo" mode="aspectFill"></image>
						<view class="fboxCol flex1 info">
							<view class="fboxRow Ycenter font28">
								<view class="flex1 fboxRow Ycenter">
									<view class="name font32 lh44 font-ell1">{{detail && detail.companyName}}</view>
									<text v-if="detail && detail.authStatus == 1" class="ml24 bwfont bw-qiye color-linear"></text>
								</view>
							</view>
							<!-- <view class="name font32 lh44">{{detail.companyName}}</view> -->
							<view class="font26 mt10 lh40" v-if="detail.industryName">{{detail && detail.industryName}}</view>
							<view class="font26 mt10 lh40 font-ell1">{{detail.areaProvinceName}}{{detail.areaCityName}}</view>
						</view>
						<view class="code" @tap="isCode = true"><text class="bwfont bw-erweima"></text></view>
					</view>
					<view class="btn-group mt40 fboxWrap Ycenter Xcenter">
						<view class="btn fboxRow Ycenter Xcenter border-radius12"  @click="isModal = true">
							<image class="icon" src="https://ebc-prod.cdn.benwunet.com/uni-static/card/img10.png" mode="aspectFit"></image>
								投递简历箱
						</view>
						<view class="btn fboxRow Ycenter Xcenter border-radius12" @click="callPhone">
							<image class="icon" src="https://ebc-prod.cdn.benwunet.com/uni-static/card/img9.png" mode="aspectFit"></image>
								拨打电话
						</view>
					</view>
				</view>
			</view>
			<view v-if="listConfig.loading == 'not-data'">
				<NotEmpty text="暂未发布职位" />
			</view>
			<view class="card-box" v-else>
				<view class="card-bd">
					<view class="card-scroll" v-if="listData.length || listConfig.loading =='loading'">
						<RecruitmentItem v-for="(item, index) in listData" :key="index" :innerData="item" type="concise" />
						<u-loadmore fontSize="24rpx" :status="listConfig.loading" />
					</view>
					<view v-if="listConfig.loading == 'list-not'">
						<NotEmpty text="暂无相关招聘" :height="300" />
					</view>
				</view>
			</view>
			<view style="height:100rpx"></view>
			<view class="fboxRow Ycenter Xcenter fixed-about">
				<text class="font24 color-6B707C">(渝)人服证字[2023]号 第4000001313号</text>
			</view>
		</view>
		<not-login bottom="160rpx" ref="notLogin" />
		<u-overlay :show="isCode" @click="isCode = false">
			<view class="warp-code">
				<view class="rect fboxCol Ycenter Xcenter" @tap.stop>
					<view class="close" @tap="isCode = false"><u-icon name="close" color="#BABABF" size="48rpx"></u-icon></view>
					<image class="code" :src="detail.resumeUrlCode" mode="aspectFill"></image>
					<view class="btn font32 fboxRow Ycenter Xcenter">保存二维码</view>
				</view>
			</view>
		</u-overlay>
	</view>
</template>

<script>
	import {companyDetail2, companyJobOther} from '@/api/recruit.js';
	import { getRequest, unitNum } from '@/static/js/common.js';
	import { utf8to16, base64decode} from '@/static/js/Base64.js';
	import RecruitmentItem from '@/components/card/recruitment-item.vue';
	import { listMixins } from '../common/list.mixins.js';
	export default {
		mixins: [listMixins],
		components:{RecruitmentItem},
		data() {
			return {
				theme: getApp().globalData.appTheme,
				globalColor: getApp().globalData.globalColor,
				detail:{},
				isApp: false,
				listConfig: {
					current: 1,
					size: 10,
					count: 0,
					loading: 'loading'
				},
				listData: [],
				companyId: getApp().globalData.companyId,
				statusBarHeight: 0,
				isLogin: true,
				isCode: false // 是否显示企业招聘二维码
			}
		},
		onLoad(option) {
			if(option && option.benwu){
				let benwu = utf8to16(base64decode(option.benwu))
				this.benwu = option.benwu
				const token = {
					access_token: getRequest(benwu,'token'),
					companyId: getRequest(benwu,'companyId'),
					statusBarHeight: getRequest(benwu,'statusBarHeight'),
					authStatus: getRequest(benwu,'authStatus'),
				}
				getApp().globalData.statusBarHeight = token.statusBarHeight
				getApp().globalData.companyId = token.companyId
				this.companyId = token.companyId
				uni.setStorageSync('bw_params', JSON.stringify(token));
				this.getDetail()
			}else if(option && option.companyId){
				this.companyId = option.companyId
				this.getDetail()
			}
			if(option && option.isApp){
				this.isApp = option.isApp == 1 ? true : false
			}else{
				const {bw_link} = getApp().getBWData(['bw_link'])
				this.isApp = bw_link.isApp == 1 ? true : false
			}
			const { bw_params } = getApp().getBWData(['bw_params'])
			this.statusBarHeight = getApp().globalData.statusBarHeight || bw_params.statusBarHeight
			this.getInit()
		},
		onShow() {
		},
		methods: {
			goPage(){
				this.$pageTo('/recruit/enterprise/index?companyId='+this.companyId)
			},
			getDetail(){
				companyDetail2({id: this.companyId}).then(res=>{
					this.isLogin = true
					getApp().globalData.companyInfo = res.data
					getApp().globalData.companyId = res.data.companyId
					uni.setStorageSync('bw_company_info', JSON.stringify(res.data));
					this.detail = res.data
				}).catch(err=>{
					this.isLogin = false
					if(err.code == 401006){
						this.$refs.notLogin.openLogin({
							show: true,
							position: 'center'
						})
					}
				})
			},
			callPhone() {
				uni.makePhoneCall({
					phoneNumber: this.detail.mobile
					//仅为示例
				});
			},
			getInit(){
				this.listConfig = {
					current: 1,
					size: 20,
					count: 0,
					loading: 'loading'
				}
				this.listData = []
				this.getList()
			},
			getList(){
				const { current, size, loading} = this.listConfig
				companyJobOther({ ...this.listConfig, companyId: this.companyId})
				.then(res => {
					this.listData = this.listData.concat(res.data.list);
					this.listLoading(res);
				})
				.catch(err => {
					if (err.code == 401006) {
						this.getList();
					}
				});
			},
		},
		onReachBottom() {
			this.listMore();
		},
	}
</script>

<style lang="scss" scoped>
	.action-btn{width: 78rpx;height: 88rpx ;}
	
	
	.warp-code{ position: relative; display: flex; align-items: center;justify-content: center; width: 100%; height: 100%;background-color: var(--controllerBgColor);}
	.warp-code .code{width: 480rpx;height: 480rpx;overflow: hidden;}
	.warp-code .btn{ margin: 160rpx 0 0; width: 400rpx;height: 88rpx;background: #E8EDF1;border-radius: 12rpx;}
	.warp-code .close{position: absolute;top: 20rpx ;right: 40rpx;}	
	
	
[data-theme='night-theme'] {
	.wrap{padding: 112rpx 0 0;background: url('https://ebc-prod.cdn.benwunet.com/uni-static/img3.3.0/recruit/bg3.png') no-repeat top center/contain;}
}
[data-theme='lightBlue-theme'] {
	.bg-head{padding: 88rpx 0 0;background: linear-gradient(180deg, var(--navViewStartColor) 0%, var(--navViewCenterColor) 32%, rgba(255,255,255,0) 100%);}
}
.management-hd{padding: 24rpx 24rpx 0;}
.management-hd .avatar{margin: 0 30rpx 0 0; width: 100rpx;height: 100rpx;overflow: hidden;border-radius: 12rpx;;}
.management-hd .btn{width: 160rpx;height: 48rpx;}
.management-hd .name{color: var(--titleFontColor);}
.management-hd .code .bwfont{color: var(--senderViewColor);font-size: 36rpx}
.management-hd .info{ color: var(--contentFontLightColor);}
.management-hd .icon{ margin-left: 9rpx; width: 40rpx; height: 40rpx}

.completion{margin-top: 18rpx;}


.info-group{ padding: 50rpx 0 32rpx;}
.action-item{position: relative;}
.action-item::before{content: '';position: absolute;left: 0;top: 50%;margin-top: -24rpx;height: 48rpx;width: 1rpx; background-color:  rgba(255,255,255,0.08);}
.action-item:first-child::before{display: none;}

.card-scroll{padding:24rpx;}
.fixed-about{position: absolute;bottom: 66rpx;left: 0;right: 0;}

.btn-group { margin-bottom: 16rpx; font-weight: 500;}
.btn-group .btn { padding: 32rpx; height: 88rpx; width: 328rpx; color: var(--senderViewColor); background: var(--pureButtonBackOneColor); border: 1rpx solid var(--buttonOutlineOneColor);}
.btn-group .btn:nth-child(odd) { margin-right: 14rpx; }
.btn-group .icon { margin-right: 12rpx; width: 64rpx; height: 64rpx; }

</style>
